     window.onload = function() {
        var stage = new Kinetic.Stage({
          container: 'container',
          width: 578,
          height: 200
        });
        var layer = new Kinetic.Layer();

        var hexagon = new Kinetic.RegularPolygon({
          x: stage.getWidth() / 2,
          y: stage.getHeight() / 2,
          sides: 6,
          radius: 70,
          fill: 'red',
          stroke: 'black',
          strokeWidth: 5
        });

        layer.add(hexagon);
        stage.add(layer);

        var amplitude = 150;
        var period = 2000;
        // in ms
        var centerX = stage.getWidth() / 2;

        var anim = new Kinetic.Animation({
          func: function(frame) {
            hexagon.setX(amplitude * Math.sin(frame.time * 2 * Math.PI / period) + centerX);
          },
          node: layer
        });

        anim.start();
      };